﻿using Microsoft.Practices.Prism.StoreApps;
using System.ComponentModel;

namespace Sumc.Client.ModernUI.Views
{
    public sealed partial class TransportPage : VisualStateAwarePage
    {
        public TransportPage()
        {
            this.InitializeComponent();
        }

        protected override void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var dataContext = this.DataContext as ViewModel;
            dataContext.PropertyChanged += DataContextPropertyChanged;
        }

        protected override void OnNavigatedFrom(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
            var dataContext = this.DataContext as ViewModel;
            dataContext.PropertyChanged -= DataContextPropertyChanged;
        }

        private void DataContextPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Directions")
            {
                this.DirectionsGriViewZoomOut.ItemsSource = this.DirectionsViewSource.View.CollectionGroups;
            }
        }
    }
}
